package com.kinyx.framework.db.vo;

import javax.persistence.Column;

import org.junit.Assert;
import org.junit.Test;

import com.kinyx.framework.db.configs.NamingStrategy;

public class MappingHandler_Tester_load_column_name {

	public class Bean {

		// 没有配置，则按照命名策略。
		@SuppressWarnings("unused")
		private String ColumnNameNo;

		// 标注@Column，但注解值为空，按照命名策略。
		@Column(name = "")
		private String ColumnNameBlank;

		// 标注@Column，有注解值，取注解值。
		@Column(name = "foo")
		private String ColumnName;

	}

	@Test
	public void test() throws NoSuchFieldException, SecurityException {
		final NamingStrategy ns = new NamingStrategy();
		Assert.assertEquals("COLUMN_NAME_NO", MappingHandler.load_column_name(Bean.class.getDeclaredField("ColumnNameNo"), ns));

		Assert.assertEquals("COLUMN_NAME_BLANK", MappingHandler.load_column_name(Bean.class.getDeclaredField("ColumnNameBlank"), ns));
		Assert.assertEquals("foo", MappingHandler.load_column_name(Bean.class.getDeclaredField("ColumnName"), ns));
	}

}
